package com.samuel.scope;


import com.samuel.AppConfig;
import com.samuel.aspect.DemoAnnocationService;
import com.samuel.aspect.DemoMethodService;
import com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @date:2017/11/21
 * @time: 11:46
 * @author:zhaoyang
 * @desc:启动Spring
 **/
public class SpringScopeApplication {


    public static void main(String[] args) {

        // 获取Spring注解配置类的上下文
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppScopeConfig.class);

        DemoService demoService1 = context.getBean(DemoService.class);
        DemoService demoService2 = context.getBean(DemoService.class);

        ScopeDemoService scopeDemoService = context.getBean(ScopeDemoService.class);
        ScopeDemoService scopeDemoService2 = context.getBean(ScopeDemoService.class);

        System.out.println(demoService1.equals(demoService2));//true

        System.out.println(scopeDemoService.equals(scopeDemoService2));//false
        //关闭上下文
        context.close();
    }

}

